//
//  HMStatusToolBar.swift
//  微博
//
//  Created by 郭鉴增 on 2016/12/10.
//  Copyright © 2016年 郭鉴增. All rights reserved.
//

import UIKit
//微博首页底部toolBar
class HMStatusToolBar: UIView {

    var statusViewModel: HMStatusViewModel? {
        didSet {
            
            
            retweetButton.setTitle(statusViewModel?.retweetCountContent, for: .normal)
            commentButton.setTitle(statusViewModel?.commentCountContent, for: .normal)
            unlikeButton.setTitle(statusViewModel?.unlikeCountContent, for: .normal)
        }
    }
    
    
    //MARK: - 懒加载
    //转发
    private lazy var retweetButton: UIButton = {
       let button = UIButton(imageName: "timeline_icon_retweet", backgroundImageName: "timeline_card_bottom_background", title: "转发", titleColor: UIColor.gray, fontSize: 14)
        return button
    }()
    //评论
    private lazy var commentButton: UIButton = {
        let button = UIButton(imageName: "timeline_icon_comment", backgroundImageName: "timeline_card_bottom_background", title: "评论", titleColor: UIColor.gray, fontSize: 14)
        return button
    }()
    //赞
    private lazy var unlikeButton: UIButton = {
        let button = UIButton(imageName: "timeline_icon_unlike", backgroundImageName: "timeline_card_bottom_background", title: "赞", titleColor: UIColor.gray, fontSize: 14)
            return button
    }()

    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    private func setupUI() {
        addSubview(retweetButton)
        addSubview(commentButton)
        addSubview(unlikeButton)
        
        retweetButton.snp_makeConstraints { (make) in
            make.leading.equalTo(self)
            make.top.equalTo(self)
            make.bottom.equalTo(self)
            make.width.equalTo(commentButton)
        }
        commentButton.snp_makeConstraints { (make) in
            make.leading.equalTo(retweetButton.snp_trailing)
            make.top.equalTo(self)
            make.bottom.equalTo(self)
            make.width.equalTo(unlikeButton)
        }
        unlikeButton.snp_makeConstraints { (make) in
            make.trailing.equalTo(self)
            make.top.equalTo(self)
            make.bottom.equalTo(self)
            make.leading.equalTo(commentButton.snp_trailing)
        }
        let firstLineView = addChildLineView()
        let secondLineView =  addChildLineView()
        
        firstLineView.snp_makeConstraints { (make) in
            make.centerX.equalTo(retweetButton.snp_trailing)
            make.centerY.equalTo(self)
        }
        secondLineView.snp_makeConstraints { (make) in
            make.centerX.equalTo(commentButton.snp_trailing)
            make.centerY.equalTo(self)
        }
        
    }
//添加子视图竖线的方法
    private func addChildLineView() -> UIImageView {
        let imageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
        addSubview(imageView)
        return imageView
    }
    
}
